package com.hzdl.goods.config;

import com.hzdl.goods.entity.Test;
import com.hzdl.goods.repository.TestRepository;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

@Configuration
public class DataInitializer {

    @Bean
    public CommandLineRunner initData(TestRepository testRepository) {
        return args -> {
            // 创建测试数据
            Test test1 = new Test();
            test1.setName("测试数据1");
            
            Test test2 = new Test();
            test2.setName("测试数据2");
            
            Test test3 = new Test();
            test3.setName("测试数据3");
            
            // 保存测试数据
            testRepository.saveAll(Arrays.asList(test1, test2, test3));
        };
    }
} 